<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
</head>
<body>
    <div id='app'>
        {{msg}}
        =====
        <brother></brother>
        <hr>
        <sister></sister>
    </div>
    <script type='text/javascript'>
        var  Bus=new  Vue()
        var  brother={
            template:`<div class='brother'>
                我是哥哥
                <button @click='bb'>我是哥哥</button>
                ===={{b1}}
            </div>`,
            data(){
                return {
                    b1:''
                }
            },
            methods:{
                bb(){
                    Bus.$emit('mm','我要给你介绍一个男朋友')
                },

                bfunc(message){
                    console.log(message,222);
                    this.b1=message
                }
            },
            mounted(){
                Bus.$on('nn',this.bfunc)
            }

        }

        var  sister={
            template:`<div class='sister'>
                我是妹妹
                <button @click='ss'>我是妹妹</button>
                ===={{s1}}
            </div>`,
            data(){
                return {
                    s1:''
                }
            },
            methods:{
                sFunc(message){
                    console.log(message,1111);
                    this.s1=message
                },

                ss(){
                    Bus.$emit('nn','我要给你介绍一个女朋友')
                }
            },
            mounted(){
                Bus.$on('mm',this.sFunc)
            }
        }
        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue'
            },
            components:{
                brother,
                sister
            }
        });
    </script>
</body>
</html>